package models

import (
	"github.com/beego/beego/v2/client/orm"
)

type PointInfo struct {
	Id            int     `orm:"auto;pk;column(id)"` // Auto-increment and primary key
	SiteCode      string  `orm:"size(255);column(site_code)"`
	RegionalName  string  `orm:"size(255);column(regional_name)"`
	SiteName      string  `orm:"size(255);column(site_name)"`
	Lat           float64 `orm:"size(255);column(lat)"`
	Lng           float64 `orm:"size(255);column(lng)"`
	Precise       string  `orm:"size(255);column(precise)"`
	Confidence    string  `orm:"size(255);column(confidence)"`
	Comprehension string  `orm:"size(255);column(comprehension)"`
	Level         string  `orm:"size(255);column(level)"`
	AnalysLevel   string  `orm:"size(255);column(analys_level)"`
}

func init() {
	// Register your model
	orm.RegisterModel(new(PointInfo))
}

func GetPointMap() map[string]PointInfo {
	list := make([]PointInfo, 0)
	pointMap := make(map[string]PointInfo)
	orm.NewOrm().QueryTable("point_info").All(&list)
	for _, point := range list {
		pointMap[point.SiteCode] = point
	}
	return pointMap
}
